Problem: A local gift shop sold bags of candy and cookies for Halloween. Bags of candy cost $$7.00$, and bags of cookies cost $$2.50$, and sales equaled $$31.50$ in total. There were $5$ more bags of cookies than candy sold. Find the number of bags of candy and cookies sold by the gift shop.
Explanation: Let $x$ equal the number of bags of candy and $y$ equal the number of bags of cookies. The system of equations is then: ${7x+2.5y = 31.5}$ ${y = x+5}$ Since we already have solved for $y$ in terms of $x$ , we can use substitution to solve for $x$ and $y$ Substitute ${x+5}$ for $y$ in the first equation. ${7x + 2.5}{(x+5)}{= 31.5}$ Simplify and solve for $x$ $ 7x+2.5x + 12.5 = 31.5 $ $ 9.5x+12.5 = 31.5 $ $ 9.5x = 19 $ $ x = \dfrac{19}{9.5} $ ${x = 2}$ Now that you know ${x = 2}$ , plug it back into $ {y = x+5}$ to find $y$ ${y = }{(2)}{ + 5}$ ${y = 7}$ You can also plug ${x = 2}$ into $ {7x+2.5y = 31.5}$ and get the same answer for $y$ ${7}{(2)}{ + 2.5y = 31.5}$ ${y = 7}$ $2$ bags of candy and $7$ bags of cookies were sold.